<?php

namespace IMooc;

class Factory
{
    public static function createDatabase()
    {
        $db = Database::getInstance();
        Register::_set('db1', $db);
        return $db;
    }

    public static function getUser($id)
    {
        $key = 'user_' . $id;
        $user = Register::_get($key);
        if (!$user) {
            $user = new User($id);
            Register::_set($key, $user);
        }
        return $user;
    }
}